Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes "InvalidOperationException" errors by performing async operations in SemaphoreSlim #796

Merged
merged 20 commits into from
Nov 19, 2020

Conversation

cheenamalhotra
Copy link
Member

@cheenamalhotra cheenamalhotra commented Nov 13, 2020

Fixes #459 #54 #786 #792
Rework over PR #579 with helpful ideas from @roji and @DavoudEshtehari

This PR fixes the issue where below exception would occur randomly due to SslStream.WriteAsync collisions.

System.InvalidOperationException: Invalid operation. The connection is closed.
   at Microsoft.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode, Boolean canAccumulate)

The design change introduces use of SemaphoreSlim with SNISslStream and SNINetworkStream overrides to ensure only 1 task is allowed to read/write to stream asynchronously at a time.

Not fixed in this issue

@cheenamalhotra cheenamalhotra changed the title Fixes "InvalidOperationException" errors by performing async write operations in Semaphore Concurrent Queue Fixes "InvalidOperationException" errors by performing async operations in Semaphore Concurrent Queue Nov 13, 2020
@cheenamalhotra cheenamalhotra added the 📈 Performance Issues that are targeted to performance improvements. label Nov 17, 2020
@cheenamalhotra cheenamalhotra changed the title WIP: Fixes "InvalidOperationException" errors by performing async operations in Semaphore Concurrent Queue Fixes "InvalidOperationException" errors by performing async operations in Semaphore Concurrent Queue Nov 18, 2020
@cheenamalhotra cheenamalhotra changed the title Fixes "InvalidOperationException" errors by performing async operations in Semaphore Concurrent Queue Fixes "InvalidOperationException" errors by performing async operations in SemaphoreSlim Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📈 Performance Issues that are targeted to performance improvements.
Projects
None yet
7 participants